package cn.lsh.spark.streaming;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class SoecketServer {

	public static void main(String[] args) throws Exception {
		ServerSocket server = new ServerSocket(9999);
		System.out.println("等待客户端连接...");
		Socket clientSocket = server.accept();
		System.out.println("客户端[" + clientSocket.getInetAddress().getHostAddress() + "]连接成功");
		OutputStream outputStream = clientSocket.getOutputStream();
		PrintStream printStream = new PrintStream(outputStream);
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String line = scanner.next();
			if (line != null && line.length() > 0) {
				printStream.println(line);
				printStream.flush();
			}
		}
	}

}
